package demo;

import org.neo4j.driver.*;

import java.util.List;

public class Demo {

    public static void main(String[] args) {
        try (Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("username", "password"));
             Session session = driver.session()) {

            String query = "MATCH (node1:NodeLabel {fclass: 'pitch'})," +
                    "      (node2:NodeLabel {fclass: 'pitch'})," +
                    "      (node3:NodeLabel {fclass: 'building'})" +
                    "WITH [node1, node2, node3] AS regionNodes" +
                    "RETURN regionNodes";

            Result result = session.run(query);

//            while (result.hasNext()) {
//                Record record = result.next();
//                // 获取名为regionNodes的列表
//                List<Value> regionNodes = record.get("regionNodes").asList();
//
//                // 在这里可以将列表中的节点信息存储到你想要的数据结构中
//                for (Value node : regionNodes) {
//                    // 处理每个节点的逻辑
//                    // 例如：String nodeName = node.get("name").asString();
//                }
//            }
        }
    }
}
